package de.dhbw.minf12.mas.voter;

import de.dhbw.minf12.mas.Permutation;
import de.dhbw.minf12.mas.logic.AbstractTargetFunctionLogic;

/**
 * Abstrakte Voter Klasse
 * @author flo
 *
 */
public abstract class AbstractVoter {
	AbstractTargetFunctionLogic targetFunction;

	public AbstractVoter(AbstractTargetFunctionLogic pTargetFunction) {
		super();
		this.targetFunction = pTargetFunction;
	}
	
	public int getSolutionValue(Permutation permutation){
		return this.targetFunction.calculateSolutionValue(permutation);
	}
	
	public int getJobCount(){
		return this.targetFunction.getJobCount();
	}
	
	/**
	 * Gibt zurück, ob der pCandidateContract besser ist als der pCurrentContract.
	 * @param pContract
	 * @param pCurrentContract
	 * @return
	 */
	public boolean vote(Permutation pCandidateContract, Permutation pCurrentContract){
		return this.targetFunction.calculateSolutionValue(pCandidateContract) <= this.targetFunction.calculateSolutionValue(pCurrentContract);
	}
}
